<template>
    <!-- 分包商入库编辑 -->
    <div class="e-form">
        <div
            class="tabs warningTabs"
            v-if="Object.keys(basicFormData).length != 0"
        >
            <el-tabs
                tab-position="left"
                v-model="tabsName"
                @tab-click="onChangeTab"
            >
                <!-- 基本信息 -->
                <el-tab-pane
                    label="基本信息"
                    name="baseInfo"
                    :disabled="clickTabFlag"
                ></el-tab-pane>
                <el-tab-pane
                    label="资质信息"
                    name="aptitude"
                    :disabled="clickTabFlag"
                ></el-tab-pane>
                <el-tab-pane
                    label="企业主要业绩"
                    name="firmPerformance"
                    :disabled="clickTabFlag"
                ></el-tab-pane>
                <el-tab-pane
                    label="企业主要管理人"
                    name="firmAdmin"
                    :disabled="clickTabFlag"
                ></el-tab-pane>
                <el-tab-pane
                    label="附件信息"
                    name="accessory"
                    :disabled="clickTabFlag"
                ></el-tab-pane>
                <el-tab-pane
                    label="审核历史"
                    name="auditHistory"
                    :disabled="clickTabFlag"
                ></el-tab-pane>
                <el-tab-pane
                    label="变更历史"
                    name="alteration"
                    :disabled="clickTabFlag"
                ></el-tab-pane>
                <el-tab-pane
                    label="评价历史"
                    name="evaluationHistory"
                    :disabled="clickTabFlag"
                ></el-tab-pane>
                <div>
                    <!-- 基本信息 -->
                    <div id="baseInfoCon" class="con">
                        <div class="e-form">
                            <div class="tabs">
                                <div class="tabs-title" id="baseInfo">
                                    基本信息
                                </div>
                                <div style="width: 100%" class="form">
                                    <el-form
                                        :model="basicFormData"
                                        :rules="rules"
                                        ref="basicFormData"
                                        label-width="150px"
                                    >
                                    <BillTop title="分包商编辑" @cancel="handleClose"></BillTop>
                                        <el-row>
                                            <el-col :span="12">
                                                <el-form-item
                                                    label="统一社会信用代码："
                                                    prop="creditCode"
                                                >
                                                    <el-input
                                                        v-model="
                                                            basicFormData.creditCode
                                                        "
                                                        placeholder="请填写"
                                                        maxlength="18"
                                                    ></el-input>
                                                </el-form-item>
                                            </el-col>
                                            <el-col :span="12">
                                                <el-form-item
                                                    label="分包商名称："
                                                    prop="subcontractorName"
                                                >
                                                    <el-input
                                                        v-model="
                                                            basicFormData.subcontractorName
                                                        "
                                                        maxlength="100"
                                                        placeholder="请填写"
                                                    ></el-input>
                                                </el-form-item>
                                            </el-col>
                                        </el-row>
                                        <el-row>
                                            <el-col :span="12">
                                                <el-form-item
                                                    label="分包商类型"
                                                    prop="subcontractorTypeKey"
                                                >
                                                    <el-checkbox
                                                        :indeterminate="
                                                            isIndeterminate
                                                        "
                                                        v-model="checkAll"
                                                        @change="
                                                            handleCheckAllChange
                                                        "
                                                        >全选</el-checkbox
                                                    >
                                                    <el-checkbox-group
                                                        v-model="
                                                            basicFormData.subcontractorTypeKey
                                                        "
                                                        @change="
                                                            handleCheckedCitiesChange
                                                        "
                                                    >
                                                        <el-checkbox
                                                            v-for="item in typeList"
                                                            :key="item.kvId"
                                                            :label="item.kvKey"
                                                            :value="item.kvId"
                                                        ></el-checkbox>
                                                    </el-checkbox-group>
                                                </el-form-item>
                                            </el-col>
                                            <el-col :span="12">
                                                <el-form-item
                                                    label="法人代表："
                                                    prop="deputy"
                                                >
                                                    <el-input
                                                        v-model="
                                                            basicFormData.deputy
                                                        "
                                                        placeholder="请填写："
                                                    ></el-input>
                                                </el-form-item>
                                            </el-col>
                                        </el-row>
                                        <el-row>
                                            <el-col :span="12">
                                                <el-form-item
                                                    label="注册地址："
                                                    prop="addressDetail"
                                                >
                                                    <SelectAddr
                                                        v-model="
                                                            basicFormData.addressDetail
                                                        "
                                                        lazy
                                                        showCountry
                                                        style="width: 100%"
                                                    ></SelectAddr>
                                                </el-form-item>
                                            </el-col>
                                            <el-col v-if="isShow" :span="12">
                                                <el-form-item
                                                    label="固定工作地址："
                                                    prop="fixAddressDetail"
                                                >
                                                    <!-- 详细地址 -->
                                                    <SelectAddr
                                                        v-model="
                                                            basicFormData.fixAddressDetail
                                                        "
                                                        lazy
                                                        showCountry
                                                        style="width: 100%"
                                                    ></SelectAddr>
                                                </el-form-item>
                                            </el-col>
                                        </el-row>
                                        <el-row>
                                            <el-col :span="12">
                                                <el-form-item
                                                    label="联系电话："
                                                    prop="contactTel"
                                                >
                                                    <el-input
                                                        v-model="
                                                            basicFormData.contactTel
                                                        "
                                                        placeholder="请填写"
                                                    ></el-input>
                                                </el-form-item>
                                            </el-col>
                                            <el-col :span="12">
                                                <el-form-item
                                                    label="注册资本（万元）："
                                                    prop="registerCapital"
                                                >
                                                    <el-input
                                                        v-model="
                                                            basicFormData.registerCapital
                                                        "
                                                        placeholder="请填写"
                                                        v-enterFloat2
                                                    ></el-input>
                                                </el-form-item>
                                            </el-col>
                                        </el-row>
                                        <el-row>
                                            <el-col :span="12">
                                                <el-form-item label="传真：" prop="fax">
                                                    <el-input
                                                        v-model="
                                                            basicFormData.fax
                                                        "
                                                        placeholder="请填写"
                                                    ></el-input>
                                                </el-form-item>
                                            </el-col>
                                            <el-col :span="12">
                                                <el-form-item
                                                    label="邮箱："
                                                    prop="email"
                                                >
                                                    <el-input
                                                        v-model="
                                                            basicFormData.email
                                                        "
                                                        placeholder="请填写"
                                                    ></el-input>
                                                </el-form-item>
                                            </el-col>
                                        </el-row>
                                        <el-row>
                                            <el-col :span="12">
                                                <el-form-item
                                                    label="纳税类别："
                                                    prop="taxTypeKey"
                                                >
                                                    <el-radio-group
                                                        @change="
                                                            radioChange($event)
                                                        "
                                                        v-model="
                                                            basicFormData.taxTypeKey
                                                        "
                                                    >
                                                        <el-radio
                                                            v-for="item in payTaxesTypeList"
                                                            :key="item.kvId"
                                                            :label="item.kvKey"
                                                            :disabled="
                                                                item.disabled
                                                            "
                                                            :value="
                                                                item.kvValue
                                                            "
                                                        ></el-radio>
                                                    </el-radio-group>
                                                </el-form-item>
                                            </el-col>
                                            <el-col :span="12">
                                                <el-form-item label="邮编：" prop="postCode">
                                                    <el-input
                                                        v-model="
                                                            basicFormData.postCode
                                                        "
                                                          v-enterInteger1
                                                        placeholder="请填写"
                                                    ></el-input>
                                                </el-form-item>
                                            </el-col>
                                        </el-row>
                                        <el-row>
                                            <el-col :span="12">
                                                <el-form-item
                                                    label="增值税一般纳税人资格查询"
                                                    ><a
                                                        href="https://etax.sichuan.chinatax.gov.cn/"
                                                        target="_blank"
                                                        >查询</a
                                                    >
                                                </el-form-item>
                                            </el-col>
                                            <el-col :span="12">
                                                <el-form-item
                                                    label="四川住房城乡建设厅信息查询"
                                                >
                                                    <a
                                                        href="http://202.61.88.188/xxgx/index.aspx"
                                                        target="_blank"
                                                        >查询</a
                                                    ></el-form-item
                                                >
                                            </el-col>
                                        </el-row>
                                        <el-row>
                                            <el-col :span="12">
                                                <el-form-item
                                                    label="信用信息查询："
                                                >
                                                    <a
                                                        href="http://www.gsxt.gov.cn/index.html"
                                                        target="_blank"
                                                        >查询</a
                                                    >
                                                </el-form-item>
                                            </el-col>
                                            <el-col :span="12">
                                                <el-form-item
                                                    label="管理单位："
                                                >
                                                    {{
                                                        basicFormData.manageOrgName
                                                    }}
                                                    <!-- <el-input
                                                        v-model="
                                                            basicFormData.manageOrgName
                                                        "
                                                        placeholder="请填写"
                                                    ></el-input> -->
                                                </el-form-item>
                                            </el-col>
                                        </el-row>
                                        <el-row>
                                            <el-col :span="12">
                                                <el-form-item
                                                    label="是否为境外单位："
                                                    prop="isAbroadUnit"
                                                >
                                                    <el-switch
                                                        :width="60"
                                                        v-model="
                                                            basicFormData.isAbroadUnit
                                                        "
                                                        class="main-el-switch"
                                                        active-color="#13ce66"
                                                        inactive-color="#D2D2D2"
                                                        active-value="1"
                                                        inactive-value="0"
                                                        active-text="是"
                                                        inactive-text="否"
                                                        @change="
                                                            isAbroadUnitChange
                                                        "
                                                    >
                                                    </el-switch>
                                                </el-form-item>
                                            </el-col>
                                            <el-col :span="12">
                                                <el-form-item label="录入人：">
                                                    {{
                                                        basicFormData.founderName
                                                    }}
                                                </el-form-item>
                                            </el-col>
                                        </el-row>
                                        <el-row>
                                            <el-col :span="12">
                                                <el-form-item
                                                    label="信用等级："
                                                >
                                                    <span>
                                                        {{
                                                            basicFormData.creditLevel ==
                                                            '0'
                                                                ? '待定'
                                                                : basicFormData.creditLevel ==
                                                                  '1'
                                                                ? 'A'
                                                                : basicFormData.creditLevel ==
                                                                  '2'
                                                                ? 'B'
                                                                : basicFormData.creditLevel ==
                                                                  '3'
                                                                ? 'C'
                                                                : basicFormData.creditLevel ==
                                                                  '4'
                                                                ? 'D'
                                                                : basicFormData.creditLevel ==
                                                                  '5'
                                                                ? 'S'
                                                                : ''
                                                        }}</span
                                                    >
                                                </el-form-item>
                                            </el-col>
                                            <el-col :span="12">
                                                <el-form-item label="状态：">
                                                    {{
                                                        statusLable(
                                                            basicFormData.state
                                                        )
                                                    }}
                                                </el-form-item>
                                            </el-col>
                                        </el-row>
                                        <el-row v-if="isShow">
                                            <el-form-item
                                                label="企业基本情况："
                                                prop="basicInfo"
                                            >
                                                <el-input
                                                    type="textarea"
                                                    :rows="2"
                                                    placeholder="请输入内容"
                                                    maxlength="500"
                                                    show-word-limit
                                                    v-model="
                                                        basicFormData.basicInfo
                                                    "
                                                >
                                                </el-input>
                                            </el-form-item>
                                        </el-row>
                                        <el-row v-if="isShow">
                                            <el-col :span="12">
                                                <el-form-item
                                                    label="企业注册建造师数量："
                                                    prop="registeredConstructorQty"
                                                >
                                                    <el-input
                                                        v-model="
                                                            basicFormData.registeredConstructorQty
                                                        "
                                                         v-enterInteger1
                                                        placeholder="请填写"
                                                    ></el-input>
                                                </el-form-item>
                                            </el-col>
                                            <el-col :span="12">
                                                <el-form-item
                                                    label="中级及以上职称人员数量："
                                                    prop="aboveTitleQty"
                                                >
                                                    <el-input
                                                        v-model="
                                                            basicFormData.aboveTitleQty
                                                        "
                                                         v-enterInteger1
                                                        placeholder="请填写"
                                                    ></el-input>
                                                </el-form-item>
                                            </el-col>
                                        </el-row>
                                        <el-row v-if="isShow">
                                            <el-col :span="12">
                                                <el-form-item
                                                    label="持有岗位证书的施工现场管理人员数量："
                                                    prop="certificateQty"
                                                >
                                                    <el-input
                                                        v-model="
                                                            basicFormData.certificateQty
                                                        "
                                                         v-enterInteger1
                                                        placeholder="请填写"
                                                    ></el-input>
                                                </el-form-item>
                                            </el-col>

                                            <el-col :span="12">
                                                <el-form-item
                                                    label="持有安全C证人员数量："
                                                    prop="safetyCertificateQty"
                                                >
                                                    <el-input
                                                        v-model="
                                                            basicFormData.safetyCertificateQty
                                                        "
                                                         v-enterInteger1
                                                        placeholder="请填写"
                                                    ></el-input>
                                                </el-form-item>
                                            </el-col>
                                        </el-row>
                                        <el-row v-if="isShow">
                                            <el-col :span="12">
                                                <el-form-item
                                                    label="正常缴纳社保人数："
                                                    prop="paySocialSecurityQty"
                                                >
                                                    <el-input
                                                        v-model="
                                                            basicFormData.paySocialSecurityQty
                                                        "
                                                         v-enterInteger1
                                                        placeholder="请填写"
                                                    ></el-input>
                                                </el-form-item>
                                            </el-col>

                                            <el-col :span="12">
                                                <el-form-item
                                                    label="经考级或培训合格的中级工以上技术工人数量："
                                                    prop="passedTrainingQty"
                                                >
                                                    <el-input
                                                        v-model="
                                                            basicFormData.passedTrainingQty
                                                        "
                                                         v-enterInteger1
                                                        placeholder="请填写"
                                                    ></el-input>
                                                </el-form-item>
                                            </el-col>
                                        </el-row>
                                    </el-form>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- 资质信息 -->
                    <div id="aptitudeCon" class="con">
                        <div class="tabs-title" id="aptitude">资质信息</div>
                        <aptitude-index
                            :billId="billid"
                            bucketName="outer"
                            :aptitudeTables.sync="aptitudeTable"
                            :is-table-row-class="tableRowClass"
                            :subcontractor-type-value="
                                this.basicFormData.subcontractorTypeValue
                            "
                            :is-abroad-unit="this.basicFormData.isAbroadUnit"
                            :credit-code-son="this.basicFormData.creditCode"
                            :aptitudeSend.sync="aptitudeSend"
                            :outerNames="this.basicFormData.subcontractorName"
                            @getAptitudeData="getAptitudeData"
                            @setError="setError"
                            ref="aptitude"
                        />
                    </div>
                    <!-- 企业主要业绩 -->
                    <div id="firmPerformanceCon" class="con">
                        <div class="tabs-title" id="firmPerformance">
                            企业主要业绩
                        </div>
                        <firm-performance
                            :billId="billid"
                            bucketName="outer"
                            :firmPerformanceTables.sync="firmPerformanceTable"
                            :is-table-row-class="tableRowClass"
                            :firmPerformanceSend.sync="firmPerformanceSend"
                            @getFirmPerformanceData="getFirmPerformanceData"
                            :outerNames="this.basicFormData.subcontractorName"
                            @setError="setError"
                            ref="firmPerformance"
                        />
                    </div>

                    <!-- 企业主要管理人 -->
                    <div id="firmAdminCon" class="con">
                        <div class="tabs-title" id="firmAdmin">
                            企业主要管理人
                        </div>
                        <firm-admin
                            :billId="billid"
                            bucketName="outer"
                            :is-table-row-class="tableRowClass"
                            :firmAdminTables.sync="firmAdminTable"
                            :subcontractor-type-value="
                                this.basicFormData.subcontractorTypeValue
                            "
                            :firmAdminSend.sync="firmAdminSend"
                            :is-abroad-unit="this.basicFormData.isAbroadUnit"
                            :outerNames="this.basicFormData.subcontractorName"
                            @getFirmAdminData="getFirmAdminData"
                            @setError="setError"
                            ref="firmAdmin"
                        />
                    </div>

                    <!-- 附件信息 -->
                    <div id="attachCon" class="con">
                        <div class="tabs-title" id="accessory">附件信息</div>
                        <outerAttach
                            :billId="billid"
                            bucketName="outer"
                            :attachTable.sync="attachTable"
                            :is-table-row-class="tableRowClass"
                            :subcontractor-type-value="
                                this.basicFormData.subcontractorTypeValue
                            "
                            :is-abroad-unit="this.basicFormData.isAbroadUnit"
                            :outerNames="this.basicFormData.subcontractorName"
                            :isSend.sync="isSend"
                            @getAttachData="getAttachData"
                            @setError="setError"
                            ref="attach"
                        />
                    </div>

                    <!-- 审核历史 -->
                    <div id="auditHistoryCon" class="con">
                        <div class="tabs-title" id="auditHistory">审核历史</div>
                        <ComExaHistory
                            :billType="parseInt(billid)"
                            @getAuditHistory="getAuditHistory"
                            :tableData="tableData"
                            ref="ComExaHistory"
                        />
                    </div>
                    <!-- 变更历史 -->
                    <div id="alterationCon" class="con">
                        <div class="tabs-title" id="alteration">变更历史</div>
                        <ChangeHistory
                            :billType="billid"
                            :alterationTable="alterationTable"
                            ref="ChangeHistory"
                        ></ChangeHistory>
                    </div>
                    <!-- 评价历史 -->
                    <div id="evaluationHistoryCon" class="con">
                        <div class="tabs-title" id="evaluationHistory">
                            评价历史
                        </div>
                        <evaluationHistory
                            billType="60401"
                            :billId="billid"
                            ref="evaluationHistoryCon"
                        />
                    </div>
                </div>
            </el-tabs>
        </div>
        <div id="seat" :style="{ height: seatHeight + 'px' }"></div>
        <div class="buttons">
            <ComExaButtons
                :auditState="auditState"
                :state="basicFormData.state"
                @exas="exas"
            />
            <el-button @click="handleClose" size="small">取消</el-button>
        </div>
    </div>
</template>

<script>
import SelectAddr from '@/components/common/addrComp'
import '@/utils/jquery.scrollTo.min'
import { mapMutations } from 'vuex'
import { showSuccessPop, openAppClient, throttle, showLoading, hideLoading } from '@/utils/common'
import subcontractorChange from '@/api/OutsourcingartyAdmin/subcontractorAdmin/subcontractorChange.js'
// 资质信息
import aptitudeIndex from '@/pages/OutsourcingartyAdmin/subcontractorAdmin/changeCom/aptitudeIndex'
// 企业主要业绩
import firmPerformance from '@/pages/OutsourcingartyAdmin/subcontractorAdmin/changeCom/firmPerformance'

// 企业主要管理人
import firmAdmin from '@/pages/OutsourcingartyAdmin/subcontractorAdmin/changeCom/firmAdmin'
//审核历史
import ComExaHistory from '@/components/common/exaHistory.vue'
// 附件信息
import outerAttach from '@/pages/OutsourcingartyAdmin/subcontractorAdmin/changeCom/outerAttach'
// 评价历史
import evaluationHistory from '@/pages/OutsourcingartyAdmin/subcontractorAdmin/changeCom/evaluationHistory'
//审核
import examine from '@/api/OutsourcingartyAdmin/subcontractorAdmin/examine.js'
// 变更历史
import ChangeHistory from '@/pages/OutsourcingartyAdmin/subcontractorAdmin/changeCom/changeHistory'
import call from '@/api/OutsourcingartyAdmin/getAllType.js'
// 分包商
import {
    qualificationAdd,
    performanceAdd,
    staffAdd,
    addEnclosure,
    subcontractorBasicInformation,
    saveSubcontractor,
    toVoid
} from '@/api/OutsourcingartyAdmin/subcontractorAdmin/subcontractor.js'
import ComExaButtons from '@/components/common/exaButtons'
// import AttachComp from '@/components/common/attachIndex'
import fn from '@/utils/checkEmpty.js'
import { creditCodeVerification, isName, isPhone, isEmail, isPostCode, isFax } from '@/utils/rules'
let oldRouter = {} // 上一个页面来源
export default {
    components: {
        SelectAddr,
        aptitudeIndex,
        firmPerformance,
        firmAdmin,
        evaluationHistory,
        ComExaHistory,
        outerAttach,
        ChangeHistory,
        ComExaButtons
    },
    // 统一信用代码验证
    data () {
        return {
            bucketName: 'OutsourcingartyAdmin', //模块名
            tabsName: 'baseInfo',
            form: {
                name: '',
                region: '',
                date1: '',
                date2: '',
                delivery: false,
                type: [],
                resource: '',
                desc: ''
            },
            value: '',
            textarea: '',
            screenWidth: 0,
            screenHeight: 0,
            lastConHeight: 0, //最后一个区域高度
            winEvent: {}, //保存事件，跳转页面的时候，结束事件，优化性能
            clickTabFlag: false, // 如果手动点击时，则不做滚动事件逻辑，只有滚动屏幕时才走滚动事件逻辑
            //基本信息表单数据
            basicFormData: {
                creditCode: '', //统一社会信用代码
                subcontractorName: '', //分包商名称
                deputy: '', //法人代表
                contactTel: '', //联系电话
                registerCapital: '', //注册资本
                fax: '', //传真
                email: '', //邮箱
                taxType: '', //纳税类别
                postCode: '', //邮编
                manageOrgName: '', //管理单位
                isAbroadUnit: '', //是否为境外单位
                creditLevelName: '', //信用等级
                state: 0, //状态
                basicInfo: '', //企业基本情况
                registeredConstructorQty: '', //企业注册建造师数量
                aboveTitleQty: '', //中级及以上职称人员数量
                certificateQty: '', //持有岗位证书的施工现场管理人员数量
                safetyCertificateQty: '', //持有安全C证人员数量
                paySocialSecurityQty: '', //正常缴纳社保人数
                passedTrainingQty: '', //经考级或培训合格的中级工以上技术工人数量
                taxTypeKey: '', //纳税类别id
                taxTypeValue: '', //纳税类别名字
                billid: '', //单据id
                addressDetail: '', //注册详细地址
                fixAddressDetail: '', //详细固定地址
                subcontractorTypeKey: [], //分包商类型【名字】
                subcontractorTypeValue: [], //分包商类型【值】
                founderId: '', //录入人id
                founderName: '' //录入人名字
            },

            //变更历史分页
            paging: {
                billId: '',
                limit: 10,
                page: 1
            },
            //类型列表
            typeList: [],
            //纳税类别列表
            payTaxesTypeList: [],
            certificateType: [], //证书类型
            orgId: '', //机构id
            orgName: '', //机构名称
            id: '', //唯一id
            userName: '',
            isSkip: false, //是否跳转
            isIndeterminate: true,
            checkAll: false, //是否全选
            isShow: true, //是否显示企业详情填写
            aptitudeTable: [], //资质信息表格数据
            firmPerformanceTable: [], //企业主要业绩表格数据
            attachTable: [], //附件信息表格数据
            auditHistoryTable: [], //审核历史表格数据
            firmAdminTable: [], //企业主要管理人表格数据
            tableRowClass: true, //是否展示组件clss
            creditCodeSon: '', //传给子组件的统一社会信用代码
            isSend: false, //附件是否验证成功
            baseSend: false, //基础信息是否验证成功
            aptitudeSend: false, //资质信息是否验证成功
            firmPerformanceSend: false, //企业主要业绩是否验证成功
            firmAdminSend: false, //主要管理人是否验证成功
            isabroad: true, //是否选择了境外单位
            alterationTable: [], //变更历史列表数据
            outerNames: '', //传给子组件的外包方名字
            errorList: [], //控制导航栏感叹号的显示
            auditState: {}, //按钮状态
            tableData: [], //审核历史数据
            newBasicFormData: {}, //处理过后的基础数据

            // 审核对象
            commit: {
                billId: '', //	单据Id
                billType: 6040, //单据编码
                freeNextUnitIndex: 0, //下一步审核步骤
                freeNextUser: '', //	下一步审核人ID
                isPass: true, //审核是否通过
                isShareInAudit: true, //是否共享审核节点
                opinion: '' //审核意见
            },

            // 验证
            rules: {
                // 统一社会信用代码
                creditCode: [
                    {
                        required: true,
                        validator: creditCodeVerification,
                        trigger: 'blur'
                    }
                ],
                //分包商名称
                subcontractorName: [
                    {
                        required: true,
                        message: '请输入分包商名称',
                        trigger: 'blur'
                    }
                ],
                //注册地址
                addressDetail: [
                    {
                        required: true,
                        message: '请选择注册地址',
                        trigger: 'change'
                    }
                ],
                //法人代表
                deputy: [
                    {
                        required: true,
                        validator: isName,
                        trigger: 'blur'
                    }
                ],
                //纳税类别
                taxTypeKey: [
                    {
                        required: true,
                        message: '请选择纳税类别',
                        trigger: 'change'
                    }
                ],
                //分包商类型
                subcontractorTypeKey: [
                    {
                        required: true,
                        message: '请选择分包商类型',
                        trigger: 'change'
                    }
                ],
                //电话
                contactTel: [
                    {
                        required: true,
                        validator: isPhone,
                        trigger: 'blur'
                    }
                ],
                //邮箱
                email: [
                    {  validator: isEmail, trigger: 'blur' }
                ],
                //邮编
                postCode: [
                    {
                        validator: isPostCode,
                        trigger: 'blur'
                    }
                ],
                //传真
                fax: [
                    {
                        validator: isFax,
                        trigger: 'blur'
                    }
                ],
                //注册资本
                registerCapital: [
                    {
                        required: true,
                        message: '请输入注册资本',
                        trigger: 'blur'
                    }
                ],

                //企业基本情况
                basicInfo: [
                    {
                        required: true,
                        message: '请输入企业基本情况',
                        trigger: 'blur'
                    }
                ],
                //是否为境外单位
                isAbroadUnit: [
                    {
                        required: true,
                        message: '请选择是否为境外单位',
                        trigger: 'change'
                    }
                ],
                // 固定地址
                fixAddressDetail: [
                    {
                        required: true,
                        message: '请选择固定地址',
                        trigger: 'change'
                    }
                ],
                //企业注册建造师数量
                registeredConstructorQty: [
                    {
                        required: true,
                        message: '请输入企业注册建造师数量',
                        trigger: 'blur'
                    }
                ],
                //中级及以上职称人员数量
                aboveTitleQty: [
                    {
                        required: true,
                        message: '请输入中级及以上职称人员数量',
                        trigger: 'blur'
                    }
                ],
                //持有岗位证书的施工现场管理人员数量
                certificateQty: [
                    {
                        required: true,
                        message: '请输入持有岗位证书的施工现场管理人员数量',
                        trigger: 'blur'
                    }
                ],
                //持有安全C证人员数量
                safetyCertificateQty: [
                    {
                        required: true,
                        message: '请输入持有安全C证人员数量',
                        trigger: 'blur'
                    }
                ],
                //正常缴纳社保人数
                paySocialSecurityQty: [
                    {
                        required: true,
                        message: '请输入正常缴纳社保人数',
                        trigger: 'blur'
                    }
                ],
                //经考核或培训合格的中级工以上技术工人数量
                passedTrainingQty: [
                    {
                        required: true,
                        message:
                            '请输入经考核或培训合格的中级工以上技术工人数量',
                        trigger: 'blur'
                    }
                ]
            }
        }
    },
    computed: {
        // 填补底部空白，以使高度够滚动
        seatHeight () {
            return this.screenHeight - 72 - this.lastConHeight
        },
        // 判断状态
        statusLable () {
            return param => {
                const state = this.$store.state.equip.equipData.state
                const obj = state.find(x => x.value == param)
                if (obj !== undefined) {
                    return obj.label
                }
            }
        }
    },
    created () {
        this.billid = this.$route.query.billid
        let data = JSON.parse(localStorage.getItem('vuex'))
        this.orgId = data.userInfo.orgInfo.orgId
        this.orgName = data.userInfo.orgInfo.orgName
        this.basicFormData.founderName = localStorage.getItem('userName')
        this.id = this.$route.query.id
        this.getTypeData() //进入页面获取类型选择框数据
        this.getBasicData() //进入页面就获取基本信息数据
        this.getList() //进入页面获取变跟历史记录
        this.getCurrentUnitInfo() //获取流程按钮
    },
    watch: {
        //给错误标签加上提醒
        errorList: newData => {
            const tabs = document.querySelectorAll('.el-tabs__item')
            tabs.forEach(DOM => {
                const { childNodes } = DOM
                if (childNodes.length > 1) {
                    DOM.removeChild(childNodes[1])
                }
            })
            newData.forEach(item => {
                const itemDom = document.querySelector(`#tab-${item}`)
                var element = document.createElement('i')
                element.className = 'el-icon-warning-outline warning'
                itemDom.appendChild(element)
            })
        }
    },
    // 进入页面之前拿到上个页面的来源
    beforeRouteEnter (to, from, next) {
        oldRouter = from
        next()
    },
    // 进入页面之后删掉
    beforeRouteLeave (to, from, next) {
        oldRouter = null
        next()
    },
    mounted () {
        // 如果是新增保存后点击“继续”跳转过来的，则定位到第2个tab
        if (oldRouter.path === '/subcontractorAdd') {
            // 将名字改为第二个详情
            this.tabsName = 'aptitude'
            this.$nextTick(() => {
                // 手动触发滚动事件
                this.onChangeTab({ name: 'aptitude' })
            })
        }
        // 获取最后一个内容区域的高度，计算底部空白
        this.getLastConHeight()
        // 保存所有tabName
        const arr = [
            'baseInfo',
            'aptitude',
            'firmPerformance',
            'evaluate',
            'auditHistory',
            'alteration',
            'accessory'
        ]
        this.tabArr = arr
        let $idsTop = []
        const onScroll = () => {
            // 如果手动点击时，则不做滚动事件逻辑，只有滚动屏幕时才走滚动事件逻辑
            if (this.clickTabFlag) {
                return
            }
            if (!$idsTop[$idsTop.length - 1]) {
                $idsTop = arr.map(item => {
                    const $item = document.getElementById(item)
                    let itemTop = null
                    if ($item) {
                        itemTop = $item.offsetTop
                    }
                    return itemTop
                })
            }
            const scrollTop =
                document.documentElement.scrollTop || document.body.scrollTop
            // 倒序查找
            let curLocal = 0
            for (let len = $idsTop.length, i = len - 1; i >= 0; i--) {
                let item = $idsTop[i]
                if (scrollTop + 1 >= item) {
                    curLocal = i
                    break
                }
            }
            // 设置对应tabName
            this.tabsName = arr[curLocal]
        }
        this.winEvent.onScroll = onScroll
        window.addEventListener('scroll', this.winEvent.onScroll)
        this.screenWidth = document.documentElement.clientWidth - this.topHeight
        this.screenHeight = document.documentElement.clientHeight - this.topHeight
        const onResize = () => {
            this.screenWidth = document.documentElement.clientWidth - this.topHeight
            this.screenHeight = document.documentElement.clientHeight - this.topHeight
            $idsTop = arr.map(item => {
                const itemTop = document.getElementById(item).offsetTop
                return itemTop
            })
        }
        this.winEvent.onResize = throttle(onResize, 500)
        window.addEventListener('resize', this.winEvent.onResize)
    },
    beforeDestroy () {
        window.removeEventListener('scroll', this.winEvent.onScroll)
        window.removeEventListener('resize', this.winEvent.onResize)
    },
    methods: {
        ...mapMutations(['setPopConfirm', 'setAuditParams']),
        //去变更新增页面
        changePage () {
            const billid = this.basicFormData.id
            if (this.alterationTable.length > 0) {
                if (
                    this.alterationTable[this.alterationTable.length - 1]
                        .state == 0
                ) {
                    // 草稿状态
                    if (
                        this.alterationTable[this.alterationTable.length - 1]
                            .founderName == localStorage.getItem('userName')
                    ) {
                        // 录入人
                        this.$router.push({
                            path: '/subcontractorChangeEdit',
                            query: { billid }
                        })
                    } else {
                        // 非录入人
                        this.$router.push({
                            path: '/subcontractorChangeShow',
                            query: { billid }
                        })
                    }
                } else if (
                    this.alterationTable[this.alterationTable.length - 1]
                        .state == 1
                ) {
                    //审核中
                    this.$router.push({
                        path: '/subcontractorChangeShow',
                        query: { billid }
                    })
                } else {
                    //已审核去新增变更
                    this.$router.push({
                        path: '/subcontractorChangeAdd',
                        query: { billid }
                    })
                }
            } else {
                this.$router.push({
                    path: '/subcontractorChangeAdd',
                    query: { billid }
                })
            }
        },
        //获取分包商类型数据
        getTypeData () {
            call.getCredentialTree({ name: '外包方类型', id: '0' }).then(
                res => {
                    let id = ''
                    // 获取想要的类型id
                    res.map(item => {
                        if (item.kvKey == '分包商') {
                            id = item.kvId
                        }
                    })
                    call.getCredentialTree({ name: '外包方类型', id: id }).then(
                        res => {
                            this.typeList = res
                        }
                    )
                }
            )
            call.getCredential('纳税类别').then(res => {
                this.payTaxesTypeList = res
            })
        },
        //获取基本信息数据
        getBasicData () {
            this.$Ajax
                .httpGet({
                    url: '/outer/subcontractor/findById',
                    params: {
                        hasDtls: false,
                        id: this.billid
                    },
                    headers: {
                        'Content-Type': 'application/x-www-form-urlencoded'
                    }
                })
                .then(res => {
                    // 判断外包方类型不为空，则转为数组
                    if (res.subcontractorTypeKey) {
                        res.subcontractorTypeKey =
                            res.subcontractorTypeKey.split(',')

                    }
                    // 判断外包方类型不为空，则转为数组
                    if (res.subcontractorTypeValue) {
                        res.subcontractorTypeValue =
                            res.subcontractorTypeValue.split(',')
                    }
                    // 将请求回来的数据赋值
                    res.isAbroadUnit = res.isAbroadUnit + ''
                    this.basicFormData = res
                    // 调用判断境外单位的方法
                    this.isAbroadUnitChange(res.isAbroadUnit)
                    // 调用选择方法，将数据全选
                    this.handleCheckedCitiesChange(
                        res.subcontractorTypeKey
                    )
                })
        },
        // 获取最后一个内容区域的高度，计算底部空白
        getLastConHeight () {
            let si = setInterval(() => {
                // 因为dom异步加载，通过轮询找到渲染后的dom，获取高度
                if (document.getElementById('evaluationHistoryCon')) {
                    const lastConHeight = document.getElementById(
                        'evaluationHistoryCon'
                    ).offsetHeight
                    this.lastConHeight = lastConHeight
                    clearInterval(si)
                    si = null
                }
            }, 100)
        },
        // 删除方法
        ctDelete () {
            this.clientPop(
                'info',
                '确定要删除吗？数据删除后不可恢复，请谨慎操作',
                this.delent
            )
        },
        //删除回调
        delent () {
            this.$Ajax
                .httpGet({
                    url: '/outer/subcontractor/delete',
                    params: {
                        id: this.billid
                    },
                    headers: {
                        'Content-Type': 'application/x-www-form-urlencoded'
                    }
                })
                .then(res => {
                    if (res.code == 200) {
                        showSuccessPop('删除成功！')
                        this.isSkip = true
                    }
                    this.$router.push('./subcontractorWarehouse')
                })
        },
        // delData () {

        // },

        //提交
        async submit () {
            this.errorList = []
            // 调用主要管理人验证方法并将值传到父组件
            this.$refs.firmAdmin.preserve()
            // 调用主营业绩验证方法并将值传到父组件
            this.$refs.firmPerformance.preserve()
            // 调用资质信息验证方法并将值传到父组件
            this.$refs.aptitude.preserve()
            // 附件
            this.$refs.attach.preserve()
            // 基础验证
            this.BaseVerification()
            if (
                this.isSend &&
                this.baseSend &&
                this.aptitudeSend &&
                this.firmPerformanceSend &&
                this.firmAdminSend
            ) {
                await this.saveBase(), //基础信息
                Promise.all([
                    this.saveFirmAdmin(), //企业主要管理人
                    this.saveFirmPerformance(), //企业主营业绩
                    this.saveAptitude(), //资质信息
                    this.saveAttach() //附件信息
                ])
                    .then(async () => {
                        this.commit.billId = this.billid
                        subcontractorChange.findcommit(this.commit).then(() => {
                            this.clientPop('suc', '提交成功')
                            // 保存成功置空数据
                            this.firmAdminTable = []
                            this.firmPerformanceTable = []
                            this.aptitudeTable = []
                            this.attachTable = []
                            this.$router.replace('/subcontractorWarehouse')
                            this.getCurrentUnitInfo()
                        })
                    })
                    .catch(() => {
                        this.clientPop('err', '提交失败')
                        this.scorllError()
                    })
            } else {
                this.clientPop('err', '提交失败')
                this.scorllError()
            }
        },
        //取消
        handleClose () {
            this.dialogVisible = false
            this.$router.replace('./subcontractorWarehouse')
        },
        // 点击标签的方法
        onChangeTab (e) {
            const height  = $('#' + e.name).offset().top
            $.scrollTo(height - this.topHeight, 500)
            // 如果手动点击时，则不做滚动事件逻辑，只有滚动屏幕时才走滚动事件逻辑
            this.clickTabFlag = true
            // 动画结束后，恢复状态
            setTimeout(() => {
                this.clickTabFlag = false
            }, 600)
        },
        // 资质信息保存
        saveAptitude () {
            return new Promise((resolve, reject) => {
                if (!this.aptitudeSend) {
                    reject('资质信息保存失败')
                    this.setError('aptitude')
                    return
                }
                qualificationAdd(this.aptitudeTable)
                    .then(() => {
                        resolve()
                        this.$refs.aptitude.qualificationList(this.billid)
                    })
                    .catch(err => {
                        this.setError('aptitude')
                        reject(err)
                    })
            })
        },
        // 企业主营业绩
        saveFirmPerformance () {
            return new Promise((resolve, reject) => {
                if (!this.firmPerformanceSend) {
                    this.setError('firmPerformance')
                    reject('主营业绩保存失败')
                    return
                }
                performanceAdd(this.firmPerformanceTable)
                    .then(() => {
                        resolve()
                        this.$refs.firmPerformance.performanceList(this.billid)
                    })
                    .catch(err => {
                        this.setError('firmPerformance')
                        reject(err)
                    })
            })
        },
        // 基础信息保存
        saveBase () {
            return new Promise((resolve, reject) => {
                if (this.baseSend) {
                    saveSubcontractor(this.newBasicFormData)
                        .then(() => {
                            resolve()

                        })
                        .catch(err => {
                            this.setError('baseInfo')
                            reject(err)
                        })
                }
            })
        },
        // 企业主要管理人
        saveFirmAdmin () {
            return new Promise((resolve, reject) => {
                if (!this.firmAdminSend) {
                    reject('主要管理人保存失败')
                    this.setError('firmAdmin')
                    return
                } else {
                    staffAdd(this.firmAdminTable)
                        .then(() => {
                            resolve()
                            this.$refs.firmAdmin.staffList(this.billid)
                        })
                        .catch(err => {
                            this.setError('firmAdmin')
                            reject(err)
                        })
                }
            })
        },
        // 附件
        saveAttach () {
            return new Promise((resolve, reject) => {
                // 调用资质信息验证方法并将值传到父组件
                if (!this.isSend) {
                    reject('附件保存失败')
                    this.setError('accessory')
                    return
                } else {
                    addEnclosure(this.attachTable)
                        .then(() => {
                            resolve()
                            this.$refs.attach.getEnclosureList(this.billid)
                        })
                        .catch(err => {
                            this.setError('accessory')
                            reject(err)
                        })
                }
            })
        },
        // 基础信息
        BaseVerification () {
            // 调用资质信息验证方法并将值传到父组件
            this.$refs.basicFormData.validate(async valid => {
                if (valid) {
                    // 如果外包商类型是数组则将数组转为字符串，否则不做处理
                    this.newBasicFormData = JSON.parse(
                        JSON.stringify(this.basicFormData)
                    )
                    if (
                        this.newBasicFormData.subcontractorTypeKey instanceof
                        Array
                    ) {
                        this.newBasicFormData.subcontractorTypeKey =
                            this.newBasicFormData.subcontractorTypeKey.join(
                                ','
                            )
                    }
                    if (
                        this.newBasicFormData.subcontractorTypeValue instanceof
                        Array
                    ) {
                        this.newBasicFormData.subcontractorTypeValue =
                            this.newBasicFormData.subcontractorTypeValue.join(
                                ','
                            )
                    }
                    // 基础信息验证成功
                    this.baseSend = true
                } else {
                    this.baseSend = false
                    this.setError('baseInfo')
                }
            })
        },
        //保存
        async save () {
            this.errorList = []
            // 调用主要管理人验证方法并将值传到父组件
            this.$refs.firmAdmin.preserve()
            // // 调用主营业绩验证方法并将值传到父组件
            this.$refs.firmPerformance.preserve()
            // 调用资质信息验证方法并将值传到父组件
            this.$refs.aptitude.preserve()
            // 附件
            this.$refs.attach.preserve()
            // 基础验证
            this.BaseVerification()
            if (
                this.isSend &&
                this.baseSend &&
                this.aptitudeSend &&
                this.firmPerformanceSend &&
                this.firmAdminSend
            ) {
                await  this.saveBase(), //基础信息
                Promise.all([
                    this.saveFirmAdmin(), //企业主要管理人
                    this.saveFirmPerformance(), //企业主营业绩
                    this.saveAptitude(), //资质信息
                    this.saveAttach() //附件信息
                ])
                    .then(async () => {
                        this.clientPop('suc', '保存成功')
                        // 保存成功置空数据
                        this.firmAdminTable = []
                        this.firmPerformanceTable = []
                        this.aptitudeTable = []
                        this.attachTable = []
                        // 刷新页面
                        this.getBasicData()
                    })
                    .catch(err => {
                        this.clientPop(err, '保存失败')
                        this.scorllError()
                    })

            } else {
                this.clientPop('err', '保存失败')
                this.scorllError()
            }
        },
        // 通过统一社会信用代码判断该公司是否符合要求
        async judgeCreditCode (row) {
            let data = await subcontractorBasicInformation({ creditCode: row })
            if (data.state == 1 || data.state == 2) {
                alert('该公司已存在系统中')
            }
        },
        // 全选
        handleCheckAllChange (val) {
            this.basicFormData.subcontractorTypeKey = val
                ? this.typeList.map(item => {
                    return item.kvKey
                })
                : []
            this.isIndeterminate = false
            // 循环拿到id
            this.typeList.map(item => {
                this.basicFormData.subcontractorTypeValue.push(item.kvValue)
            })
        },
        //外包方类型选择
        handleCheckedCitiesChange (value) {
            let checkedCount = value.length
            this.checkAll = checkedCount === this.typeList.length
            this.isIndeterminate =
                checkedCount > 0 && checkedCount < this.typeList.length
            // 通过类型判断是否是小规模纳税人
            if (value.includes('其他') && checkedCount == 1) {
                this.isShow = false
                this.payTaxesTypeList.map(item => {
                    if (item.kvValue == '1') {
                        this.$set(item, 'disabled', false)
                    }
                })
            } else {
                if(this.basicFormData.isAbroadUnit == 1) {
                    this.isShow = false
                }else{
                    this.isShow = true
                }
                if (this.basicFormData.taxTypeValue == '1') {
                    this.basicFormData.taxTypeValue = '0'
                    this.payTaxesTypeList.map(item => {
                        if (this.basicFormData.taxTypeValue == item.kvValue) {
                            this.basicFormData.taxTypeKey = item.kvKey
                        }
                    })
                }
                this.payTaxesTypeList.map(item => {
                    if (item.kvValue == '1') {
                        this.$set(item, 'disabled', true)
                    }
                })
            }
            // 循环拿到id
            this.typeList.map(item => {
                value.map(Valitem => {
                    if (item.kvKey == Valitem) {
                        this.basicFormData.subcontractorTypeValue.push(
                            item.kvValue
                        )
                    }
                })
            })
        },
        // 一般纳税人选择
        radioChange (row) {
            this.payTaxesTypeList.map(item => {
                if (row == item.kvKey) {
                    this.basicFormData.taxTypeValue = item.kvValue
                }
            })
        },
        // 是否为境外单位，判断是否显示企业详情
        isAbroadUnitChange (row) {
            let flag = false
            if(this.basicFormData.subcontractorTypeKey.includes('其他') && this.basicFormData.subcontractorTypeKey.length == 1) {
                flag = true
            }else {
                flag = false
            }
            if (row == 1 || flag) {
                this.isabroad = false
                this.isShow = false
            } else {
                this.isShow = true
            }
        },
        //判断是否为空
        checkEmpty (datas) {
            return fn.checkEmpty(datas)
        },
        // 变更历史列表查询
        async getList () {
            let data = await subcontractorChange.findByIdChangehistorList({
                id: this.billid
            })
            this.alterationTable = data
        },
        // 审核历史列表查询
        async getAuditHistory () {
            let data = await subcontractorChange.findByIdAuditHistory({
                billId: this.billid,
                billType: 6040,
                freeNextUnitIndex: 0,
                freeNextUser: '',
                isPass: true,
                isShareInAudit: true,
                opinion: ''
            })
            this.tableData = data
        },
        //根据点击不同的tab,调用不同的接口
        queryData (name) {
            switch (name) {
            // 基础信息
            case 'baseInfo':
                this.BaseVerification()
                this.saveBase()
                break
                // 资质信息
            case 'aptitude':
                this.getAptitudeData()
                break
                // 企业主要业绩
            case 'firmPerformance':
                this.getFirmPerformanceData()
                break
                // 企业主要管理人
            case 'firmAdmin':
                this.getFirmAdminData()
                break
                // 附件信息
            case 'accessory':
                this.getAttachData()
                break
            }
        },
        //设置错误标签
        setError (name) {
            if (!this.errorList.find(x => x === name)) {
                this.errorList.push(name)
            }
        },
        //跳转到第一个错误标签
        scorllError () {
            let num = this.tabArr.length
            this.errorList.forEach(item => {
                let index = this.tabArr.findIndex(x => x === item)
                num = index < num ? index : num
            })
            const obj = { name: this.tabArr[num] }
            this.tabsName = this.tabArr[num]
            this.onChangeTab(obj)
        },
        // 基础信息保存方法
        async BasicDataSave () {
            // 保存当前页面你的数据
        },
        // 获取子组件数据的方法
        // 资质信息
        async getAptitudeData (data) {
            // 如果有参数，则为删除时调用此方法，否则为保存
            if (data) {
                await qualificationAdd(data)
                this.$refs.aptitude.qualificationList(this.billid)
            } else {
                this.$refs.aptitude.preserve()
                if (this.aptitudeSend) {
                    await qualificationAdd(this.aptitudeTable)
                    this.$refs.aptitude.qualificationList(this.billid)
                }
            }
        },
        // 调用企业业绩保存方法
        async getFirmPerformanceData (data) {
            if (data) {
                await performanceAdd(data)
                this.$refs.firmPerformance.performanceList(this.billid)
            } else {
                this.$refs.firmPerformance.preserve()
                if (this.firmPerformanceSend) {
                    await performanceAdd(this.firmPerformanceTable)
                    this.$refs.firmPerformance.performanceList(this.billid)
                }
            }
        },
        // 企业主要管理人
        async getFirmAdminData (data) {
            if (data) {
                await staffAdd(data)
                this.$refs.firmAdmin.staffList(this.billid)
            } else {
                this.$refs.firmAdmin.preserve()
                if (this.firmAdminSend) {
                    await staffAdd(this.firmAdminTable)
                    this.$refs.firmAdmin.staffList(this.billid)
                }
            }
        },
        // 附件信息
        async getAttachData (data) {
            if (data) {
                await addEnclosure(data)
                this.$refs.attach.getEnclosureList(this.billid)
            } else {
                this.$refs.attach.preserve()
                if (this.isSend) {
                    await addEnclosure(this.attachTable)
                    this.$refs.attach.getEnclosureList(this.billid)
                }
            }
        },
        // 作废
        toVoidChange () {
            this.clientPop('info', '是否确认作废', this.callback)
        },
        // 作废确认回调
        async callback () {
            // 客户端弹窗弹出本地页面
            const auditParams = JSON.parse(localStorage.vuex).auditParams
            openAppClient('/nullifyDialog', '单据作废原因', async () => {
                showLoading()
                await toVoid({
                    billId: this.billid, //单据id
                    billType: '6040', //单据类型
                    nullifyCreated: '',
                    nullifyCreator: '',
                    nullifyCreatorId: '',
                    nullifyDescription: auditParams.nullifyDescription,
                    nullifyReason: auditParams.nullifyReason
                })
                    .catch(() => {
                        this.clientPop('suc', '作废失败')
                    })
                hideLoading()
            })
        },
        // 撤回
        withdrawChange () {
            this.clientPop('info', '是否确认撤回', this.callbackWithdraw)
        },
        // 撤回确认回调
        async callbackWithdraw () {
            let { code } = await examine.undoAudit({
                billId: this.billid, //单据id
                billType: '6040', //单据类型
                freeNextUnitIndex: 0,
                freeNextUser: '',
                isPass: true,
                isShareInAudit: true,
                opinion: ''
            })
            if (code == 200) {
                showSuccessPop('撤回成功')
                // 返回列表
                this.handleClose()
            } else {
                showSuccessPop('撤回失败')
            }
        },
        // 审核
        audit () {
            // 审核之前调一次保存方法
            this.errorList = []
            // 调用主要管理人验证方法并将值传到父组件
            this.$refs.firmAdmin.preserve()
            // 调用主营业绩验证方法并将值传到父组件
            this.$refs.firmPerformance.preserve()
            // 调用资质信息验证方法并将值传到父组件
            this.$refs.aptitude.preserve()
            // 附件
            this.$refs.attach.preserve()
            // 基础验证
            this.BaseVerification()
            if (
                this.isSend &&
                this.baseSend &&
                this.aptitudeSend &&
                this.firmPerformanceSend &&
                this.firmAdminSend
            ) {
                Promise.all([
                    this.saveBase(), //基础信息
                    this.saveFirmAdmin(), //企业主要管理人
                    this.saveFirmPerformance(), //企业主营业绩
                    this.saveAptitude(), //资质信息
                    this.saveAttach() //附件信息
                ])
                    .then(async () => {
                        // 客户端弹窗弹出本地页面
                        openAppClient('/exaDialog', '填写审核意见', () => {
                            // 审核拿到审核弹窗的意见
                            const auditParams = JSON.parse(
                                localStorage.vuex
                            ).auditParams
                            // 将审核意见赋值给参数传给后端
                            examine
                                .audit({
                                    billId: this.$route.query.billid,
                                    billType: 6040,
                                    freeNextUnitIndex: 0,
                                    freeNextUser: '',
                                    isPass: auditParams.isPass,
                                    isShareInAudit: true,
                                    opinion: auditParams.opinion
                                })
                                .then(() => {
                                    this.clientPop('suc', '审核成功')
                                    // 保存成功置空数据
                                    this.firmAdminTable = []
                                    this.firmPerformanceTable = []
                                    this.aptitudeTable = []
                                    this.attachTable = []
                                    // 返回列表
                                    this.handleClose()
                                })
                        }, null, null, null, 'small')
                    })
                    .catch(() => {
                        this.clientPop('err', '审核失败')
                        this.scorllError()
                    })
            } else {
                this.clientPop('err', '审核失败')
                this.scorllError()
            }
        },
        // 获取按钮状态
        getCurrentUnitInfo () {
            examine
                .getCurrentUnitInfo({
                    billId: this.$route.query.billid,
                    billType: 6040,
                    freeNextUnitIndex: 0,
                    freeNextUser: '',
                    isPass: true,
                    isShareInAudit: true,
                    opinion: ''
                })
                .then(res => {
                    this.auditState = res
                })
        },
        // 按钮组件触发事件
        exas (data) {
            switch (data) {
            case 'audit':
                this.audit() //审核
                break
            case 'undoAudit':
                this.withdrawChange() //撤回
                break
            case 'submitCommit':
                this.submit() //提交
                break
            case 'submit':
                this.save() //保存
                break
            case 'nullify':
                this.toVoidChange() //作废
                break
            case 'deleteData':
                this.ctDelete() //删除
                break
            default:
                break
            }
        }
    }
}
</script>

<style lang="scss" scoped>
.buttons {
    left: 0;
}
.e-form {
    margin-bottom: 80px;
    padding: 0 20px;
    .tabs-title::before {
        content: '';
        height: 22px;
        width: 8px;
        border-radius: 40px;
        background-color: #2e61d7;
        display: block;
        position: absolute;
        left: 20px;
        margin-right: 20px;
    }
}

.e-table {
    background: #fff;
}
// ::v-deep.el-table__body-wrapper::-webkit-scrollbar{
//      width: 6px !important; // 横向滚动条
//     height: 10px !important// 纵向滚动条
// }

::v-deep .el-table__body-wrapper::-webkit-scrollbar {
    width: 6px; // 横向滚动条
    height: 10px; // 纵向滚动条
}
// 滚动条的滑块
::v-deep .el-table__body-wrapper::-webkit-scrollbar-thumb {
    background-color: #ddd;
    border-radius: 5px;
}

.el-tab-pane {
    margin-left: -10px;
}
::v-deep .el-checkbox {
    margin: 0px 15px 5px 0px;
}
// 境外单位
::v-deep .clearPadding .vxe-cell {
    padding: 0;
}
::v-deep .clearPaddingLeft .vxe-cell {
    padding-left: 0px;
}
::v-deep {
    .main-el-switch {
        position: relative;
        .el-switch__core {
            height: 24px;
            border-radius: 12px;
            &:after {
                left: 4px;
                top: 3px;
            }
        }
        &.el-switch {
            &.is-checked {
                .el-switch__core {
                    &:after {
                        margin-left: -20px;
                        left: 100%;
                    }
                }
            }
        }
        &.is-checked {
            .el-switch__label--left {
                opacity: 0;
            }
            .el-switch__label--right {
                opacity: 1;
            }
        }
        .el-switch__label {
            position: absolute;
            top: 0;
        }
        .el-switch__label--left {
            right: 0;
            color: #999;
            z-index: 1;
            margin-right: 8px;
        }
        .el-switch__label--right {
            left: 0;
            color: #fff;
            opacity: 0;
            margin-left: 8px;
        }
    }
}
</style>
